package com.ccrfid.rmc6.service.poi;

import com.ccrfid.rmc6.entity.poi.PoiLineEntity;
import com.ccrfid.rmc6.service.amq.MqMsgProducer;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class PoiLineServiceAspect {
    @Autowired
    private MqMsgProducer mqMsgProducer;

    @AfterReturning(value = "execution(public * com.ccrfid.rmc6.service.poi.PoiLineService.createLine(..))",
            returning = "ret")
    public void afterCreateLine(PoiLineEntity ret) {
        String msg = "[" + ret.getId() + "]";
        mqMsgProducer.send2Topic("ws_line_add", msg);
    }

    @AfterReturning(value = "execution(public * com.ccrfid.rmc6.service.poi.PoiLineService.updateLine(..))",
            returning = "ret")
    public void afterUpdatePoiLine(PoiLineEntity ret) {
        String msg = "[" + ret.getId() + "]";
        mqMsgProducer.send2Topic("ws_line_update", msg);
    }

    @AfterReturning(value = "execution(public * com.ccrfid.rmc6.service.poi.PoiLineService.deleteLineById(..)) && args(id)",
            argNames = "id")
    public void afterDeletePoiLine(Long id) {
        String msg = "[" + id + "]";
        mqMsgProducer.send2Topic("ws_line_delete", msg);
    }
}
